<template>
	<view class="hotel-room-list-head">
		<view class="">
			<image src="https://bpic.588ku.com//back_origin_min_pic/24/01/13/f07c0ac433e7eb197d2a282dd184355b.jpg"
				mode="" class="grayBox"></image>
		</view>
		<view class="hotel-room-list-two">
			<view class="hotel-room-list-top"> {{ name }}</view>
			<view class="hotel-room-list-bottom" @tap="$emit('goToHotelDetailsPage')">
				<view class="hotel-room-list-left">酒店详情</view>
				<image src="/static/images/HotelRoomList/arrow.png" mode="" class="hotel-room-list-right"></image>
			</view>
		</view>
		<view class="hotel-room-list-three">
			<image src="/static/images/HotelRoomList/LocationPin.png" mode="" class="hotel-room-list-item"
				@tap="showMap"></image>
			<!-- <template v-if="iscollect">
				<image src="/static/images/HotelRoomList/favorited.png" mode="" class="hotel-room-list-item iscollect"
					@tap="$emit('isCollect')"></image>
			</template>
			<template v-else>
				<image src="/static/images/HotelRoomList/isFavorite.png" mode="" class="hotel-room-list-item iscollect"
					@tap="$emit('isCollect')">
				</image>
			</template> -->
			<image src="/static/images/HotelRoomList/share.png" mode="" class="hotel-room-list-item"
				@tap="handleShareClick"></image>
		</view>
	</view>
</template>

<script>
	import {
		record
	} from "../../api/share";

	export default {
		props: {
			iscollect: {
				type: Boolean,
				default: false
			},
			latitude: {
				type: Number,
				default: 0
			},
			longitude: {
				type: Number,
				default: 0
			},
			address: {
				type: String,
				default: ''
			},
			name: {
				type: String,
				default: ''
			}
		},
		methods: {
			handleShareClick() {
				// 调用分享房间接口
				record({
					// 这里可以添加需要传递的参数
					type: 1,
					sourceId: 1
				}).then(res => {
					console.log('分享酒店成功', res);
				}).catch(err => {
					console.error('分享酒店失败', err);
				});
			},
			showMap() {
				if (this.latitude && this.longitude) {
					uni.openLocation({
						latitude: Number(this.latitude),
						longitude: Number(this.longitude),
						address: this.address || '',
						name: this.name || '',
						scale: 18
					})
				}
			},
		},
	}
</script>

<style lang="less" scoped>
	@import "../../static/commonStyleLess/grayBox.less";

	.hotel-room-list-head {
		width: 750rpx;
		height: 220rpx;
		margin: 0 auto;
		background: #FFFFFF;
		display: flex;
		align-content: center;
		box-sizing: border-box;
		padding: 30rpx;

		.hotel-room-list-two {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			margin-left: 20rpx;

			.hotel-room-list-top {
				width: 280rpx;
				height: 48rpx;
				font-weight: 700;
				font-size: 28rpx;
				line-height: 48rpx;
				letter-spacing: 0px;
				text-align: center;
				color: #222222;
			}

			.hotel-room-list-bottom {
				display: flex;
				justify-content: flex-start;
				align-items: center;

				.hotel-room-list-left {
					width: 104rpx;
					height: 36rpx;
					font-family: 'PingFang SC';
					font-weight: 400;
					font-size: 26rpx;
					line-height: 36rpx;
					letter-spacing: 0px;
					text-align: center;
					color: #979797;
				}

				.hotel-room-list-right {
					width: 32rpx;
					height: 32rpx;
				}
			}
		}

		.hotel-room-list-three {
			display: flex;
			align-items: flex-end;
			margin-left: 70rpx;

			.hotel-room-list-item {
				width: 48rpx;
				height: 48rpx;
				border-width: 2rpx;
				margin-left: 30rpx;
			}
		}
	}
</style>